<script>
	import {
		addToday,
		addUser,
		getSystem
	} from 'api/system.js'
	export default {
		globalData: {
			screenWidth: 0,
			statusBarHeight: 0,
			statusBarHeight: 0,
		},
		onLaunch: function() {
			let list = []
			let keys = uni.getStorageInfoSync().keys
			keys.map(i => {
				if (i.indexOf('novel_') > -1) {
					let s = uni.getStorageSync(i)
					let o = JSON.parse(JSON.stringify(s.info))
					o.time = s.time
					o.currentchapters = s.currentchapters + 1
					o.total = s.chapters.length
					o.status = s.status
					if (o.total != 0) o.lastestchapter = s.chapters[s.chapters.length - 1].name
					list.push(o)
				}
			})
			this.$store.commit('data/SET_NOVELLIST', list)
			let {
				screenWidth,
				screenHeight,
				statusBarHeight
			} = uni.getSystemInfoSync()
			this.globalData.screenWidth = screenWidth
			this.globalData.screenHeight = screenHeight
			this.globalData.statusBarHeight = statusBarHeight
			this.$store.commit('theme/SET_STATUSBARHEIGHT', statusBarHeight)

			uni.getStorageSync('themeType') ? this.$store.commit('theme/SET_THEMETYPE', uni.getStorageSync(
				'themeType')) : null
			uni.getStorageSync('font') ? this.$store.commit('theme/SET_FONT', uni.getStorageSync('font')) : null
			uni.getStorageSync('navColor') ? this.$store.commit('theme/SET_NAVCOLOR', uni.getStorageSync('navColor')) :
				null
			uni.getStorageSync('background') ? this.$store.commit('theme/SET_BACKGROUND', uni.getStorageSync(
				'background')) : null
			uni.getStorageSync('fontSize') ? this.$store.commit('theme/SET_FONTSIZE', uni.getStorageSync('fontSize')) :
				null
			uni.getStorageSync('lineHeight') ? this.$store.commit('theme/SET_LINEHEIGHT', uni.getStorageSync(
				'lineHeight')) : null
			uni.getStorageSync('color1') ? this.$store.commit('theme/SET_COLOR1', uni.getStorageSync(
				'color1')) : null
			uni.getStorageSync('color2') ? this.$store.commit('theme/SET_COLOR2', uni.getStorageSync(
				'color2')) : null
			this.$store.dispatch('data/getWebsiteList')
			let day = new Date().getDate()
			if (day != uni.getStorageSync('Today')) {
				addToday().then(res => {
					uni.setStorageSync('Today', day)
				})
			}
			//#ifdef APP
			if (!uni.getStorageSync('UUID')) {
				addUser({
					uuid: plus.device.uuid
				}).then(res => {
					uni.setStorageSync('UUID', plus.device.uuid)
				})
			}
			//#endif

		}
	}
</script>

<style>
	/*每个页面公共css */
	@import url('./static/iconfont-weapp-icon.css');
	@import url('./static/iconfont.css');
	.uni-navbar {
		background-color: var(--background) !important;
		box-shadow: 10rpx 10rpx 15rpx var(--color1),
			-10rpx -10rpx 15rpx var(--color2);
	}
	.container.dark {
		background: #212121 !important;
		color: white !important;
		--nav_color: rgb(24, 24, 24) !important;

		--background: #212121 !important;
		--color1: #1c1c1c !important;
		--color2: #262626 !important;
		--color-main: #c8c8c8;
		--color-second: #a1a1a1;
		color: var(--color-main) !important;
	}

	.container {
		--color-main: #303133;
		--color-second: #606266;
		color: var(--color-main) !important;
		font-family: "PingFang SC", "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
	}

	/deep/ .uni-tag {
		font-weight: bolder !important;
	}

	/deep/ .uni-input-input {
		font-weight: initial !important;
	}
</style>
